package com.java.teachercode;

public class Test {

    public static void main(String[] args) {
        BreadContainer bc = new BreadContainer();
        //定义消费者
        Consumer c1 = new Consumer(bc, "c1", 180);
        Consumer c2 = new Consumer(bc, "c2", 250);
        Consumer c3 = new Consumer(bc, "c3", 250);

        //定义生产者
        Producer p1 = new Producer(bc, "p1", 180);
        Producer p2 = new Producer(bc, "p2", 250);
        Producer p3 = new Producer(bc, "p3", 250);

        //启动
        c1.start();
        c2.start();
        c3.start();
        p1.start();
        p2.start();
        p3.start();

        while (c1.isAlive() || c2.isAlive() || c3.isAlive() || p1.isAlive() || p2.isAlive() || p3.isAlive()) {
            try {
                Thread.sleep(5);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

        System.out.println("------- 执行结束，" + bc);
    }

}
